<template>  
   <header class="header">
       <nav class="navbar">
        <ul class="nav-items-wrap">
            <li class="nav-items items">
                <img src="../../static/images/logo.png" alt="">
            </li>
        </ul>
        <div  class="nav-items-wrap column" v-if="item.open ? false:true">
              <ul class="item nav-items-wrap">
                  <li><a href="#">首页</a></li>
                  <li><a href="#">关于</a></li>
                  <li><a href="#">更多</a></li>
              </ul>
        </div>
        <div  class="nav-items-wrap column" v-if="item.open?true:false" @click="change">
            <em></em>
            <em></em>
            <em></em> 
        </div>
        <div class="fiexd" v-if="show" @click="toggle">
                <ul class="menu">
                  <li @click="goto"><a href="#">首页</a></li>
                  <li @click="goto"><a href="#">关于</a></li>
                  <li @click="goto"><a href="#">更多</a></li>
                </ul> 
        </div>
       </nav>
    </header>   
</template>
<script>
import navbar from '../navbar/Navbar'
export default {
     name: 'Headers',
     data: function(){
        return {
            item:{
                open:false
            },
            show:false
        }
     },
     methods:{
       change:function(){
               this.show=true;
       },
       toggle:function(){
           this.show=false;
       },
       goto:function(e){
               e.preventDefault();      
       }
     },
     mounted : function(){
		//可用于设置自适应屏幕，根据获得的可视宽度（兼容性）判断是否显示
		let w = document.documentElement.offsetWidth || document.body.offsetWidth;
		if(w < 1000){
			this.item.open = true;
        }
     },
     components:{
         navbar:'nav'
     }
}
</script>
<style>
.header{
    background-color:rgba(0,0,0,0.2);
}
.navbar{
    padding: 10px;
    display: flex;
    flex-direction: row;
}
.nav-items-wrap{
    flex: 1;
    list-style: none;
    display: flex;
}

.nav-items{
    flex: 1;
    padding: 5px 10px;
    display: inline;
    font-size: 16px;
    font-weight: bold;
}
.items{
    flex: 1;
}
.column{
    flex-direction: column;
}
.nav-items-wrap em{
    width: 30px;
    height: 4px;
    margin-top: 8.5px;
    background-color: white;
    align-self: flex-end;
}
.item{
    text-align: center;
}
.item li{
   display: block;
   list-style: none;
   align-self: center;
}
.item li a{
    padding: 0 18px;
    text-decoration: none;
    outline: none;
    cursor: pointer;
    color: #fff;
}
.fiexd{
    position: fixed;
    width: 200px;
    height: 100%;
    top:0;
    right: 0;
    z-index: 999;
    background: rgba(0, 0, 0, .6)
}
.menu{
    margin-top: 76px;
    list-style: none;
}
.menu>li{
 padding: 10px 5px 10px 25px;
}
.menu li a{
    color: #fff;
    text-decoration: none;
    outline: none;
    cursor: pointer;
}
</style>
